package re_0905.question_threadlocal;

public class Main {
    public static final InheritableThreadLocal<String> inheritableThreadLocal = new InheritableThreadLocal<>();
    public static final ThreadLocal<String> threadLocal = new ThreadLocal<>();
    public static void main(String[] args) {

    }
    //方法一：父线程使用InheritableThreadLocal来存储数据。
    public void test1(){
        inheritableThreadLocal.set("inheritableThreadLocal");
        threadLocal.set("threadLocal");
        new Thread(()->{
            System.out.println("son\t"+inheritableThreadLocal.get());
            System.out.println("son\t"+threadLocal.get());
            new Thread(() -> {
                System.out.println("grandSon\t"+inheritableThreadLocal.get());
                System.out.println("grandSon\t"+threadLocal.get());
            }).start();
        }).start();
    }

}
